﻿namespace Resharper.Abstractions.CodeDom.Statements
{
  using JetBrains.Annotations;
  using JetBrains.ReSharper.Psi.CSharp.Tree;
  using JetBrains.ReSharper.Psi.Tree;
  using Resharper.Abstractions.CodeDom.Expressions;
  using Resharper.Abstractions.CodeDom.Statements.Blocks;
  using Resharper.Abstractions.CodeDom.Statements.DeclarationStatements;
  using Resharper.Abstractions.CodeDom.Statements.ForStatements;
  using Resharper.Abstractions.CodeDom.Statements.TryStatements;

  /// <summary>Defines the <see cref="ExpressionFactory"/> class.</summary>
  internal static class StatementFactory
  {
    #region Public Methods

    /// <summary>Gets the expression.</summary>
    /// <param name="statement">The expression.</param>
    /// <returns>Returns the expression.</returns>
    [NotNull]
    public static Statement GetStatement(IStatement statement)
    {
      if (statement is IBlock)
      {
        return new Block((IBlock)statement);
      }

      if (statement is IForStatement)
      {
        return new ForStatement((IForStatement)statement);
      }

      if (statement is ITryStatement)
      {
        return new TryStatement((ITryStatement)statement);
      }

      if (statement is IDeclarationStatement)
      {
        return new DeclarationStatement((IDeclarationStatement)statement);
      }

      return new Statement(statement);
    }

    #endregion
  }
}